/*
 *  Author: Andrew Gillies
 *  Date: 29/04/2014
 *  Description: Character class is an abstract class hosting default 
 *  variables to be used by indiviudal character sub-classes, along with getters and setters for various attributes.
 */

package com.forbiddendesert.characters;

import java.util.Vector;

import com.example.forbiddendesert.R;
import com.forbiddendesert.actions.Action;
import com.forbiddendesert.artefacts.Artefact;
import com.forbiddendesert.logic.GameObject;
import com.forbiddendesert.logic.Gear;
import com.forbiddendesert.logic.Jetpack;
import com.forbiddendesert.tiles.Tile;

import android.content.Context;

public abstract class Character extends GameObject
{	
	protected int mCanteenCapacity = 4;
	protected int mCanteenLevel = mCanteenCapacity;
	protected int mInitialTurns = 4;
	protected int mRemainingTurns = mInitialTurns;
	protected int mSandShifted = 1;
	private int[] mGridPosition;
	
	protected String mCharacterName = "";
	
	private Vector<Gear> mGears;
	private Vector<Artefact> mArtefacts;
	private Vector<Tile> mTiles;

	public Character(Context context)
	{
		super(context);
		
		mBitmap = loadBitmap(context.getResources(),R.drawable.ic_launcher);
		updateSourceRectangle();
		updateDestinationRectangle();
		setPaint();
		
		mGridPosition = new int[2];
		mGridPosition[0] = 0;
		mGridPosition[1] = 0;
 
		mX = mHalfWidth;
		mY = mHalfHeight;
		
		mWidth 	= 30;
		mHeight = 30;
		mHalfWidth 	= 15;
		mHalfHeight = 15;
		
		mGears = new Vector<Gear>();
		mArtefacts = new Vector<Artefact>();
		mTiles = new Vector<Tile>();
	}
	
	// Implement abstract methods in sub-classes
	public abstract void checkSurroundingTiles();
	public abstract void getAvailableActions();
	
	public int getRemainingTurns()
	{
		return mRemainingTurns;
	}	
	
	public void addTurns(int amount)
	{
		mRemainingTurns += amount;
	}
	
	public void emptyCanteen(int amount)
	{
		mCanteenLevel -= amount;
	}
	
	public void refillCanteen(int amount)
	{
		mCanteenLevel += amount;
	}

	public void addGear(Gear gear)
	{
		mGears.add(gear);
	}
	
	public void removeGear(Gear gear)
	{
		mGears.remove(gear);
	}
	
	public boolean hasGear(Gear gear)
	{
		if(mGears.contains(gear))
			return true;
		else
			return false;
	}
	
	public Vector<Gear> getGear()
	{
		return mGears;
	}
	
	// unimplemented method, performAction. 
	public void performAction(Action action)
	{
		if(mRemainingTurns > 0)
		{
			//check available actions
			//if(action is available)
			{
				//perform action
			}
		}
	} 
	
	public int getSandShifted()
	{
		return mSandShifted;
	}
}
